package string;

public class CharAtDemo {
    public static void main(String[] args) {
          /*          //01234567890
        String str = "www.tedu.cn";
        char s1=str.charAt(4);//获取字符串中第5个字符
        System.out.println("s1 = " + s1);
        for(int i=0;i<str.length();i++){//遍历字符串
            s1=str.charAt(i);//获取字符串中每一个字符
            System.out.print(s1+" ");//输出字符
        }
      String line="上海自来水来自海上";
        boolean flag=true;
        for(int i=0;i<line.length()/2;i++){
            char c1=line.charAt(i);
            char c2=line.charAt(line.length()-1-i);
            if(c1!=c2){
                flag=false;
                System.out.println("不是回文");
                break;
            }
        }
        if(flag==true)
        System.out.println("是回文");
*/
        /*String line="上海自来水来自海上";
        for(int i=0;i<line.length();i++){
            char c1=line.charAt(i);
            char c2=line.charAt(line.length()-i-1);
            if(c1!=c2){
                System.out.println("不");
                break;
            }
        }
        System.out.println("是回文");
    }*/
        /*String line="上海自来水来自海上";
        for(int i=0;i<line.length();i++){
            char c1=line.charAt(i);
            char c2=line.charAt(line.length()-i-1);
            if(c1!=c2){
                System.out.println("不是回文");
                return;
            }
        }
        System.out.println("是回文");*/
        String line="上海自来水来自海上";
        int i=0;
        for(;i<line.length();i++){
            char c1=line.charAt(i);
            char c2=line.charAt(line.length()-i-1);
            if(c1!=c2){
                System.out.println("不是回文");
                break;
            }
        }
        if(i==line.length()/2)
        System.out.println("是回文");
    }
}